﻿// jquery的every和some
$.fn.some = function (callback) {
    var result = false;
    var self = this;
    this.each(function (index, element) {
        if (callback(index, element, self)) {
            result = true;
            return false;
        }
    });
    return result;
};
$.fn.every = function (callback) {
    var result = true;
    var self = this;
    this.each(function (index, element) {
        if (!callback(index, element, self)) {
            result = false;
            return false;
        }
    });
    return result;
};


// 数据报表根据不同查询时间传参
function optionChange(checkedType, guid, url, boolean) {
    var returnData;
    if (checkedType === '4') {
        returnData = {
            url: url,
            data: boolean ? {
                timeType: checkedType,
                inGUIDs: guid,
                stime: $('#startTime').datebox('getValue') + " 00:00:00",
                etime: $('#endTime').datebox('getValue') + " 00:00:00"
            } : {
                    timeType: checkedType,
                    inGUID: guid,
                    stime: $('#startTime').datebox('getValue') + " 00:00:00",
                    etime: $('#endTime').datebox('getValue') + " 00:00:00"
                }
        };
        return returnData;
    } else {
        returnData = boolean ? {
            url: url,
            data: {
                timeType: checkedType,
                inGUIDs: guid
            }
        } : {
                url: url,
                data: {
                    timeType: checkedType,
                    inGUID: guid
                }
            };
        return returnData;
    }
}

// 获取图标的legend参数
function getLegend(array) {
    var legendArray = [];
    if (!!array) {
        array.forEach(function (item) {
            legendArray.push(item.name);
        })
    }
    return legendArray;
}